package com.itheima;

import java.util.ArrayList;
import java.util.LinkedList;

public class LinkedListDemo {
    public static void main(String[] args) {

        LinkedList <String>list = new LinkedList<>();



        list.addFirst("Zhang");
        list.addLast("Lisi");
        list.addLast("Wang");
        list.addLast("Zhao");
        list.addLast("mini");

        String s = list.get(3);//查询效率O(n)
        ArrayList<String> arrayList = new ArrayList<>();
        arrayList.get(3);//查询效率O(1)


        String first = list.getFirst();
        String last = list.getLast();
        System.out.println(first);
        System.out.println(last);


        //remove=removeFirst
        String removeFirst = list.removeFirst();
        String removeLast = list.removeLast();
        System.out.println(removeFirst);
        System.out.println(removeLast);

        System.out.println(list);
    }
}
